<%@ Page Language="C#" MasterPageFile="~/Main.master" AutoEventWireup="true" CodeFile="AdminPredictions.aspx.cs"
    Inherits="AdminPredictions" Title="The Forecast Exchange - Prediction management" %>

<%@ Register TagPrefix="forecast" TagName="PredictionForm" Src="~/controls/forms/PredictionForm.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <h1>
        Manage predictions</h1>
    <forecast:PredictionForm runat="server" ID="_predictionForm" />
    <asp:AccessDataSource ID="DataSourceNotYetActivePredictions" runat="server" DataFile="~/App_Data/ForecastExchange.mdb"
        SelectCommand="SELECT [ID], [Ticker], [Short_description], [End_date] FROM [Prediction] WHERE (([Is_active] = ?) AND ([Is_closed] = ?))">
        <SelectParameters>
            <asp:Parameter DefaultValue="false" Name="Is_active" Type="Boolean" />
            <asp:Parameter DefaultValue="false" Name="Is_closed" Type="Boolean" />
        </SelectParameters>
    </asp:AccessDataSource>
    <asp:AccessDataSource ID="DataSourceActivePredictions" runat="server" DataFile="~/App_Data/ForecastExchange.mdb"
        SelectCommand="SELECT [ID], [Ticker], [Short_description], [End_date], [Last_value], [Last_change] FROM [Prediction] WHERE (([Is_closed] = ?) AND ([Is_active] = ?))">
        <SelectParameters>
            <asp:Parameter DefaultValue="false" Name="Is_closed" Type="Boolean" />
            <asp:Parameter DefaultValue="true" Name="Is_active" Type="Boolean" />
        </SelectParameters>
    </asp:AccessDataSource>
    <h2>
        Planned predictions</h2>
    <asp:GridView ID="GridViewNotYetActivePredictions" runat="server" DataSourceID="DataSourceNotYetActivePredictions"
        Width="100%" AutoGenerateColumns="False" AllowPaging="True"
        AllowSorting="True" OnSelectedIndexChanged="GridViewNotYetActivePredictions_SelectedIndexChanged"
        CellPadding="2" ForeColor="#333333" GridLines="Vertical">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <Columns>
            <asp:BoundField DataField="ID" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                SortExpression="ID" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px"/>
            <asp:BoundField DataField="Ticker" HeaderText="Ticker" SortExpression="Ticker" ItemStyle-HorizontalAlign="Center"  ItemStyle-Width="50px"/>
            <asp:BoundField DataField="Short_description" HeaderText="Prediction" SortExpression="Short_description" ItemStyle-HorizontalAlign="Left"/>
            <asp:TemplateField HeaderText="End date" SortExpression="End_date" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <%# ((DateTime)Eval("End_date")).ToShortDateString()%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowSelectButton="True" ButtonType="Button" SelectText="Edit" />
        </Columns>
    </asp:GridView>
    <h2>
        Active predictions</h2>
    <asp:GridView ID="GridViewActivePredictions" runat="server" DataSourceID="DataSourceActivePredictions"
        Width="100%" AutoGenerateColumns="False" AllowPaging="True"
        AllowSorting="True" OnSelectedIndexChanged="GridViewActivePredictions_SelectedIndexChanged"
        CellPadding="2" ForeColor="#333333" GridLines="Vertical">
        <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
        <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
        <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
        <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
        <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
        <AlternatingRowStyle BackColor="#F7F7F7" />
        <Columns>
            <asp:BoundField DataField="ID" HeaderText="Id" InsertVisible="False" ReadOnly="True"
                SortExpression="ID" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px"/>
            <asp:BoundField DataField="Ticker" HeaderText="Ticker" SortExpression="Ticker" ItemStyle-HorizontalAlign="Center"  ItemStyle-Width="50px"/>
            <asp:BoundField DataField="Short_description" HeaderText="Prediction" SortExpression="Short_description" ItemStyle-HorizontalAlign="Left"/>
            <asp:TemplateField HeaderText="End date" SortExpression="End_date" ItemStyle-HorizontalAlign="Center">
                <ItemTemplate>
                    <%# ((DateTime)Eval("End_date")).ToShortDateString()%>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:CommandField ShowSelectButton="True" ButtonType="Button" SelectText="Edit" />
        </Columns>
    </asp:GridView>
</asp:Content>
